#include "StdAfx.h"
#include "ArcEditor.h"
#include "LabelTools.h"
#include "EditorHelper.h"
#include "./FunctionDrivers/FunctionDriverArc.h"

REGISTERE_EDITOR(CArcEditor);

CArcEditor::CArcEditor(void)
{

}

CArcEditor::~CArcEditor(void)
{
}

CString CArcEditor::GetID(void)
{
	return ARC_CRPE_GUID;
}

CArcInfo* CArcEditor::GetShapeInfo()
{
	return &m_Info;
}
void CArcEditor::Initialize(CAnyView* pView)
{	
	m_Info.Reset();
	m_Info.dirNormal = pView->CurPlaneNormal();

	AddSubEditor(new CPointCapture(m_Info.ptCenter),
		CArcInfo::CENTER_POINT);
	AddSubEditor(new CLengthCapture(m_Info.ptCenter, m_Info.ptStart, m_Info.dRadius),
		CArcInfo::RADIUS);
	AddSubEditor(new CAngleCapture(m_Info.ptCenter, m_Info.ptStart,
		m_Info.dirNormal, m_Info.ptEnd, m_Info.dAngle),
		CArcInfo::ANGLE);

	CModelEditor::Initialize(pView);


}


bool CArcEditor::CreatePreviewShape(void)
{
	switch(CurrentStep())
	{
	case CArcInfo::CENTER_POINT:
		break;
	case CArcInfo::RADIUS:
		break;
	case CArcInfo::ANGLE:
		{
			TopoDS_Shape shape;
			CArcBuilder builder;
			if(builder.Build(&m_Info, shape))
			{
				SetPreviewShape(shape);
				return true;
			}
		}
	}

	return false;
}

bool CArcEditor::CreateShapeLabel(TDF_Label& label)
{

	label = NewLabel(_T("Arc"));;

	m_Info.AddToLabel(label);

	Handle(CFunctionDriverArc) functionDriver;
	return ProcessFunctionDriver<CFunctionDriverArc>(label, functionDriver);
}
